import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bmfmap_example/pages/homepage/pages/Equipment_message/tool/tool.dart';

import 'Equipment_all_value_card.dart';

class Equipment_all_value extends StatefulWidget {
  Equipment_all_value({ Key key,this.typeId,this.deviceId,this.list }) : super(key: key);
  int typeId;
  int deviceId;
  List list;
  @override
  _Equipment_all_valueState createState() => _Equipment_all_valueState();
}



class _Equipment_all_valueState extends State<Equipment_all_value> {

    @override
  void initState() {
    // TODO: implement initState
    
    // print(list);

    super.initState();
    // 页面加载时调用 用来开始时访问数据库
  }

  List<Equipment_all_value_card> list = [];

  @override
  Widget build(BuildContext context) {
    print(widget.typeId);
    // print(widget.deviceId);
    return Scaffold(
      appBar: AppBar(
        title: Text(Tool.getName(widget.typeId, widget.deviceId)),
        backgroundColor: Colors.blue,
      ),
      body: Container(
        color: Colors.black12,
        padding: const EdgeInsets.all(16.0),
        child: ListView(
          children: _listbuild(),
          reverse: true, //1.设置倒序为true
        ),
      ),
    );
  }
  _listbuild() {
    list = [];
    for (var i = 0; i <  widget.list.length; i++) {
      list.add(Equipment_all_value_card(
        typeId: widget.typeId,
        deviceId: widget.deviceId,
        content: widget.list[i]['content'],
        created: widget.list[i]['created'],
      ));
    }
    
    return list;
  }
}